﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace idleQuest2010
{
    public class Monster
    {
        string name;
        int level;
        int hp;
        Random rand1;
        Random rand;
        int maxDamage;
        int minDamage;

        public Monster(string mName, int mLevel)
        {
            name = mName;
            level = mLevel;
            rand1 = new Random();
            rand = new Random(rand1.Next());
            maxDamage = (int)Math.Ceiling((level - 3) * 1.1);    //the maximum amount of damage a monster can do with a successful attack
            if (maxDamage <= 0) maxDamage = 1;
            minDamage = (maxDamage - level * 2) % level;  //the minimum amount of damage a monster can do with a successful attack
            if (minDamage <= 0) minDamage = 1;
            hp = rand.Next(level, level * 2);
        }

        public string getName()
        {
            return name;
        }

        public int attack()
        {   //attack the player. Returns the base damage done by the attack.
            return rand.Next(minDamage, maxDamage + 1);
        }

        public bool takeDamage(int damage)
        {   //get hit by a player's attack. Returns true if the attack killed the monster.
            hp -= damage;
            if (hp <= 0) return true;
            else return false;
        }
    }
}
